<?php
/**
 * Created by PhpStorm.
 * User: xiao
 * Date: 2017/6/17
 * Time: 下午1:43
 */

namespace app\domain;


use app\src\account\enmu\AccountEnmu;
use app\src\accountScore\action\AccountScoreAction;
use app\src\accountScore\logic\AccountScoreLogic;
use app\src\extend\Page;
use app\src\profit\logic\ProfitLogic;

class AccountScoreDomain extends BaseDomain
{

    /**
     * 获取账户积分(车险金)
     */
    public function getInfo()
    {
        $this->checkVersion('100');

        $account_type = $this->_post('account_type', '', 'account_type is missing');
        $account_id = $this->_post('account_id', '', 'account_id is missing');

        $result = (new AccountScoreLogic)->getScore($account_type, $account_id);

        $this->returnResult($result);
    }

    /**
     * 获取账号车现金记录
     */
    public function getAccounts(){
        $this->checkVersion('100');

        $type = $this->_post('role_type','','type is missing');
        $uid = $this->_post('uid','','uid is missing');

        $page_size = $this->_post('page_size','10');
        $page_index = $this->_post('page_index','1');
        $page = ['curpage'=>$page_index,'size'=>$page_size];
        $change_type = $this->_post('change_type','','change_type is missing');
        $score_type = AccountScoreLogic::SCORE_TYPE_1;
        $result = (new AccountScoreAction())->queryAccounts($type,$uid,$score_type,$page,$change_type);
        //$result = (new ProfitLogic())->queryAccounts($type,$uid);

        if($result['status']){
//            foreach($result['info']['list'] as &$list){
//                if($list['type'] == '0' && $list['account_id'] == $uid){
//                    $list['reason'] = '自己消费获得积分';
//                }
//            }
            $this->apiReturnSuc($result['info']);
        }else{
            $this->apiReturnErr($result['info']);
        }
    }

}